package day03;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

//@WebServlet(value = "/testServlet",loadOnStartup = 0)
public class TestServlet implements Servlet {
//public class TestServlet extends HttpServlet {
    private ServletConfig servletConfig;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println("TestServlet.init(ServletConfig)");
        this.servletConfig=servletConfig;
        init();
    }

    public void init(){
        System.out.println("TestServlet.init()");
    }

    @Override
    public ServletConfig getServletConfig() {
        return servletConfig;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("TestServlet.service(ServletRequest,ServletResponse)");
        service((HttpServletRequest) servletRequest,(HttpServletResponse) servletResponse);
    }

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("TestServlet.service(HttpServletRequest,HttpServletResponse)");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("TestServlet.destroy()");
    }
}
